<template>
	<div class="main">
		<div class="navbar">
                <van-icon name="arrow-left" size="25" @click="gohome"/>
                <h1 class="nav-header">订单页面</h1>
                <div class="nav-icon">
                    <img src="https://p0.meituan.net/scarlett/f05f61e7a8f3f45fd071c068d7a26870356.png" alt="">
                </div>
            </div> 
		<van-card v-for="(item,index) in ids" :key="item" tag="影票订单" 
		:desc="descs[index]" 
		:num="nums[index]" 
		:title="names[index]" 
		:thumb="imgs[index]"
		/>
			
	</div>
</template>

<script>
	import Vue from 'vue';
	import {
		Card
	} from 'vant';
import uri from '@/config/uri'
	Vue.use(Card);

	export default {
		data() {
			return {
				userInfo: {},
				ids:[],
				nums:[],
				imgs:[],
				descs:[],
				names:[]
			}
		},
		created() {
			this.$store.commit('common/setIsShow',false);
			let _token = this.$store.state.common._token;
			if (_token) {
				console.log(_token)
				this.$http.post("http://10.36.133.3:3000/api/v1/user/bill").then((ret) => {
					console.log(ret)

					if (ret.err == 0) {
						// 赋值给初始可变数据
						ret.msg.forEach(el => {
							this.ids.push(el[1].note);
							this.nums.push(el[2].num);
							 this.$http.get(uri.detailmovie+'?movieId='+el[1].note).then((req) => {
								console.log(req);
								this.imgs.push(req.detailMovie.img.replace('/w.h',''))
								this.descs.push(req.detailMovie.dra)
								this.names.push(req.detailMovie.filmAlias)
							 })
							
						});
							
						// this.$http.get()
					}
					console.log(this.ids);
					console.log(this.nums);
				});
			}
		},
		methods:{
			gohome(){
            this.$router.push('/logged')
        },
		},
		beforeDestroy(){
        this.$store.commit('common/setIsShow',true)
    	}
	}
</script>

<style  scoped='scoped'>
.main {
	position: absolute;
	top: 70px;
	width:100%;
}
.navbar {
        box-sizing: border-box;
        padding:0 10px 0 10px;
        position:fixed;
        top:0;
         z-index: 100;
        width:100%;
        height: 50px;
        color: #fff;
        background: #e54847;
        border-bottom: 1px solid #e54847;
        display: flex;
        align-items: center;
    } 
    .nav-header {
        margin-left: 50px;
        width:270px;
        font-size: 18px;
        font-weight: 400;
        text-align: center;
        line-height: 50px;
    }
    .nav-icon img{
        margin-left: 25px;
        margin-top:5px;
        width:17px;
        height: 16px;
    }
.van-card {
	width:100%;
}
</style>
